/*
 * @Author: 晟松
 * @Date: 2021-11-30 00:04:38
 * @LastEditors: 晟松
 * @LastEditTime: 2022-02-22 18:16:14
 * @FilePath: \mini-vue3d:\Code\node\koa2\volunteer-service\src\main\config\index.js
 * @Description:
 */
// src/main/config/index.js
import { info, error } from "@main/util/Log4jsUtil";

export default {
    // 注意static必须在jwt和cors前面，才能正常访问
    middlewares: ["globalError", "static" , "cors", "jwt"],
    jwt: {
        // 秘钥
        secret: "666666",
        // TOKEN 过期时间，数字单位默认为秒，可以写为："2 days", "10h"等形式，生成的token保存在authorization中
        expiresIn: "240h",
        // jwt自动解码后的数据，存放在ctx.state.jwtdata中,或者不设置，默认在ctx.state.user中
        // key: "jwtdata",
    },
    db: {
        username: process.env.DB_USERNAME,
        password: process.env.DB_PASSWORD,
        host: process.env.DB_HOST,
        database: process.env.DB_DATABASE,
        dialect: process.env.DB_DIALECT,
        define: {
            // 数据库字段下划线命名，匹配模型驼峰式命名
            underscored: true,
            // 禁用修改表名
            freezeTableName: true,
        },
        timezone: "+08:00",
        // 返回的时间格式配置
        dialectOptions: {
            dateStrings: true,
            typeCast: true,
        },
        logging: (sql) => info(sql),
        // 连接池
        pool: {
            max: 15,
            min: 0,
            acquire: 30000,
            idle: 10000,
        },
    },
};
